<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="10" :lg="11" :md="12" :sm="24">
            <a-form-item :label="$t('业务时间')">
              <j-date
                :show-time="{ defaultValue: moment('00:00:00', 'HH:mm:ss') }"
                valueFormat="YYYY-MM-DD HH:mm:ss"
                dateFormat="YYYY-MM-DD HH:mm:ss"
                :placeholder="$t('开始时间')"
                class="query-group-cust"
                v-model="queryParam.createTime_begin"
              ></j-date>
              <span class="query-group-split-cust"></span>
              <j-date
                :show-time="{ defaultValue: moment('23:59:59', 'HH:mm:ss') }"
                valueFormat="YYYY-MM-DD HH:mm:ss"
                dateFormat="YYYY-MM-DD HH:mm:ss"
                :placeholder="$t('结束时间')"
                class="query-group-cust"
                v-model="queryParam.createTime_end"
              ></j-date>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item :label="$t('会员信息')">
              <a-input :placeholder="$t('请输入手机号/卡号/姓名')" v-model="queryParam.memberInfo"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="8" :lg="9" :md="10" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">{{$t('查询')}}</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">{{$t('重置')}}</a-button>
              <a-button type="primary" icon="download" :loading="exloading" style="margin-left: 8px" @click="handleExportXls($t('会员存票排名'))" v-has="'BisMemberAccountChangeController:export'">{{$t('导出')}}</a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->

    <!-- table区域-begin -->
    <div>

      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :customHeaderRow="customHeaderRow"
        :customRow="customRow"
        class="j-table-force-nowrap"
        @change="handleTableChange">

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">{{$t('无图片')}}</span>
          <img v-else :src="getImgView(text)" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">{{$t('无文件')}}</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)">
            {{$t('下载')}}
          </a-button>
        </template>
      </a-table>
    </div>
  </a-card>
</template>

<script>
  import moment from 'moment'
  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'

  export default {
    name: 'MemberSaveTicket',
    mixins:[JeecgListMixin, mixinDevice],
    components: {
    },
    data () {
      return {
        description: '会员存票排名',
        moment,
        isorter: {
          column: 'lotteryValue',
          order: 'desc',
        },
        // 表头
        columns: [
          {
            title: this.$t('名次'),
            dataIndex: 'id',
            width:120,
            align:"center",
          },
          {
            title:this.$t('手机号'),
            align:"center",
            dataIndex: 'phone'
          },
          {
            title:this.$t('卡号'),
            align:"center",
            dataIndex: 'chipNo'
          },
          {
            title:this.$t('姓名'),
            align:"center",
            dataIndex: 'name'
          },
          {
            title:this.$t('存票次数'),
            align:"right",
            dataIndex: 'changeIndex',
            customRender: (text, r) => {
              text = (text ==null || text =="" || text ==undefined)?0:parseFloat(text);
              return text.toFixed(0);
            }
          },
          {
            title:this.$t('存票值'),
            align:"center",
            dataIndex: 'lotteryValue',
            customCell:function(t,r){
              return{
                style:{
                  textAlign:'right'
                }
              }
            },
            customRender: (text, r) => {
              text = (text ==null || text =="" || text ==undefined)?0:parseFloat(text);
              return text.toFixed(0);
            }
          },
        ],
        url: {
          list: "/member/bisMemberAccountChange/rankLottery",
          exportXlsUrl: "/member/bisMemberAccountChange/rankLotteryExportXls",
        },
        dictOptions:{},
        isCustom:true,
        isHideData:false,
        queryParam: {
          createTime_begin: moment().format('YYYY-MM-DD 00:00:00'),
          createTime_end: moment().format('YYYY-MM-DD 23:59:59'),
        }
      }
    },
    created() {
    },
    mounted(){
      let that=this
      document.onkeydown = function(e) {
        let key = window.event.keyCode;
        if (key== 75 && event.ctrlKey) {
          window.event.preventDefault()
          that.isHideData = false
          that.queryParam.dataType=0
          that.searchQuery()
        }
      }
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      initDictConfig(){
        this.customInit()
      },
      customInit() {
        this.isHideData = true
        this.queryParam.dataType=1
        this.loadData(1)
      },
      searchReset(){
        this.queryParam={
          createTime_begin: moment().format('YYYY-MM-DD 00:00:00'),
          createTime_end: moment().format('YYYY-MM-DD 23:59:59'),
        }
        this.selectedRowIndex = []
        this.customInit()
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>